<template>
  <!-- 日报 -->
  <div id="daily">
    <div class="topBox">
      <div class="left">
        <img :src="require('/public/img/icon11.webp')" alt="" />
        <p class="name">我的日报</p>
      </div>
      <div class="right" @click="toList">
        <p class="lable">查看全部</p>
        <el-icon class="icon"><el-icon-arrow-right /></el-icon>
      </div>
    </div>
    <div class="list" v-if="list.length != 0">
      <div
        class="item"
        v-for="(item, index) in list"
        :key="item.id"
        @click="toDetail(item)"
      >
        <div class="titleBox">
          <img
            :src="require('/public/img/daily_icon.webp')"
            alt=""
            class="icon"
          />
          <p class="title">
            {{ item.summary }}
          </p>
        </div>
        <p class="time">{{ item.createTime }}</p>
      </div>
    </div>

    <el-empty :image-size="50" v-else></el-empty>
  </div>
</template>
<script>

export default {
  name: 'notice',
  data () {
    return {
      list: [],

    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    // 获取列表
    async getList () {
      let { data } = await this.$API.daily.getDailyList.get({ limit: 4, page: 1, type: 2 })
      this.list = data
      console.log('data')
      console.log(data)
    },

    toList () {
      this.$router.push({
        path: '/home/myDaily'
      })
    },

    toDetail (row) {
      console.log(row)
      this.$router.push({
        path: "/home/myDaily/dailyDetail",
        query: {
          id: row.id,
        },

      })
    }
  }
}
</script>
<style lang="scss" scoped>
#daily {
  margin-bottom: 20px;
  padding: 30px 20px 40px 20px;
  background: #ffffff;
  border-radius: 8px;
  box-sizing: border-box;
  height: 100%;
  // min-height: 200px;
  .topBox {
    display: flex;
    justify-content: space-between;
    padding-bottom: 20px;
    border-bottom: 1px #eee solid;
  }
  .left {
    display: flex;
    align-items: center;
    .name {
      margin-left: 10px;
      font-size: 16px;
    }
  }
  .right {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #999;
    cursor: pointer;
    .icon {
      margin-left: 5px;
      font-size: 16px;
    }
  }

  .list {
    margin-top: 20px;
  }
  .item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    cursor: pointer;
    .titleBox {
      display: flex;
      align-items: center;
      width: 80%;
      font-size: 14px;
      color: #666;
    }
    .icon {
      transform: scale(0.8);
    }
    .title {
      margin-left: 10px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .time {
      color: #999;
    }
  }
  .el-empty {
    height: 100%;
  }
}
</style>